<template>
    <div class="export">
        <el-dialog title="导出字段设置" :visible="dialogVisible1" width="50%" size="mini" @close="cancel">
            <div>
                <el-transfer  :props="{
      key: 'fields',
      label: 'fieldDesc'
    }" v-model="value" :data="lists"  :titles="['全部列', '导出列']"></el-transfer>

                <div class="submit-btn">
                  
                    <el-button type="primary" @click="submit" size="small">确 定</el-button>
                    <el-button @click="cancel" size="small" class="btn-cancel">取 消</el-button>
                </div>
            
            </div>
        </el-dialog>
   
    </div>
</template>
<script>

export default {
    props:{
        dialogVisible:{
            type:Boolean,
            default:false
        },
        searchForm:{
            type:Object,
            default(){
                return {}
            }
        },
        classPath:String,
        listUrl:String,
        filedListStr:{
            type:Array,
            default(){
                return []
            }
        }
    },
    data(){
        return {
            value:[],
            dialogVisible1:false,
        }
    },
    watch:{

    },
    computed:{
        lists(){
            return this.filedListStr||[]
        }
    },
    created(){
    
        this.submit()

    },
    methods:{
        submit(){
            console.log( this.lists)
            let tps = this.lists.filter((el)=>{
                return ['id','no','outNo','createUser','createTime','createBy',"delFlag",'sort','status','updateBy'].indexOf(el.fields) == -1
            })
            let arr = []
            let temp = []
            tps.forEach((el)=>{
               if(el.fields =="updateTime"||el.fields =="updateUser"||el.fields == "remark"){
                temp.push(el)
               }else{
                arr.push(el)
               }
              
            })
            arr = arr.concat(temp)
            this.$emit('exportExcel',arr)
            this.cancel()
        },
        cancel(){
            this.$emit('update:dialogVisible',false)
        },
        
        exportFrontExcel(excelHeader,dataList){
                /**
                 * excelHeader 数组放置excel表头
                 * dataList  放列表数据数据
                 */
                if(!(Array.isArray(excelHeader)&&Array.isArray(dataList))){
                    return
                }
                let sheet = [excelHeader,dataList]
                let workSheet = this.$XLSX.utils.aoa_to_sheet(sheet)
                let workbook = this.$XLSX.utils.book_new()
                this.$XLSX.utils.book_append_sheet(workbook, workSheet, "sheet1")
                this.$XLSX.writeFileXLSX(workbook, "exportTable.xlsx");
            },
    }
}
</script>
<style lang="scss" scoped>
 .title-wrap{
  .title-txt {
    padding-left: 6px;
  }
 }
 .form-title{
    font-weight: 700;
    margin-bottom: 0px;
 }
 .submit-btn{
  display: flex;
  flex-direction: row-reverse;

 }
 .btn-cancel{
    margin-right: 15px;
 }
 .export::v-deep .el-transfer-panel__item {
    width: auto;
}
</style>
